using System.Collections.Generic;
using TBit.Compile;
using Token = TBit.Compile.ASMCompile.Token;

namespace TBit.Instrcutions {
    public static class DD {// DD V,DVR
        public static int Compile(List<Token> tokens,VM vm,int i) {
            return ASMCompile.StructureInstruction_OPCODE_V_DVR(Opcode.DD,tokens,vm,i);
        }
        public static Instruction Create(string a,RegisterIndex b) {
            Instruction inst = new Instruction();
            inst.opcode = Opcode.DD;
            inst.args.Add(new InstructionArgData(a));
            inst.args.Add(new InstructionArgData(b));
            return inst;
        }
        public static Instruction Create(string a,Data b) {
            Instruction inst = new Instruction();
            inst.opcode = Opcode.DD;
            inst.args.Add(new InstructionArgData(a));
            inst.args.Add(new InstructionArgData(b));
            return inst;
        }

        public static Instruction Create(string a,string b) {
            Instruction inst = new Instruction();
            inst.opcode = Opcode.DD;
            inst.args.Add(new InstructionArgData(a));
            inst.args.Add(new InstructionArgData(b));
            return inst;
        }

        public static int Run(VM vm,Instruction inst){
            InstructionArgData arg1 = inst.args[0];
            InstructionArgData arg2 = inst.args[1];
            string variable_name = arg1.variable;
            Data val = Mov.GetDVRData(vm,ref arg2);
            vm.WriteData(variable_name,val);
            return 1;
        }
    }
}